local UnitPrefab = require("Data.Prefab").unit
local UINodes = require("Data.UINodes")
local class = require("Utils.ClassUtils").class

---@class SpaceShipController
---@field new fun(): SpaceShipController
local SpaceShipController = class("SpaceShipController")



function SpaceShipController:ctor()
	  self.isFly = false
      self.flySpeed =30
      self.spaceShip= LuaAPI.query_unit("沙漠山体151")
      self.startPoint = self.spaceShip.get_position()
end

function SpaceShipController:setCanFly(canFly)
	print("可以飞:", canFly)
    LuaAPI.global_send_custom_event("flying",nil);
    -- self.isFly = canFly
    -- print("setCanFly:", self.isFly)
    
end


function SpaceShipController:stopFly(canFly)
	print("飞行结束:", canFly)
        LuaAPI.global_send_custom_event("stopfly",nil);
    self.spaceShip.set_position(self.startPoint)

end

function SpaceShipController:update()
    -- if self.isFly then
    --     print("flying")
    --     self.spaceShip.set_linear_velocity(math.Vector3(0, self.flySpeed, 0))
    -- end
end

return SpaceShipController
